package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void insertDish(Dish dish);

    /**
     * 菜品列表分页
     *
     */
    Page<DishVO> pageDishQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 修改菜状态
     */
    @AutoFill(OperationType.UPDATE)
    void dishStatus(Dish dish);

    /**
     * ID查询
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish queryDish(Integer id);

    /**
     * ID查询 Long
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish queryDishL(Long id);

    /**
     * 分类ID查询 Long
     * @param id
     * @return
     */
    @Select("select * from dish where category_id = #{id}")
    List<Dish> queryDishCategory(Integer id);

    @Select("select * from dish where category_id = #{categoryId} and status = #{status}")
    List<Dish> list(Dish dish);

    /**
     * 修改菜品信息
     */
    @AutoFill(OperationType.UPDATE)
    void modifyDishInfo(Dish dish);


    void deleteBatch(List<Long> ids);

    //根据id获取
    @Select("select * from dish where id = #{dishId}")
    Dish getById(Long dishId);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
